package com.woniu.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResData<T> {
    private Integer code;
    private String msg;
    private  T data;


    public ResData<T> ok(T t) {
        return new ResData<>(ResponseCodeEnum.LOGIN_SUCCESS.getCode(), t);
    }


    public ResData<T> ok() {
        return new ResData<>(ResponseCodeEnum.LOGIN_SUCCESS.getCode(), "ok");
    }

    public ResData<T> fail() {
        return new ResData<>(ResponseCodeEnum.FAIL.getCode(),ResponseCodeEnum.FAIL.getMsg());
    }


    public ResData<T> NO_DATA() {
        return new ResData<>(ResponseCodeEnum.NO_DATA.getCode(),ResponseCodeEnum.NO_DATA.getMsg());
    }
    public ResData<T> CODE_INVALID() {
        return new ResData<>(ResponseCodeEnum.CODE_INVALID.getCode(),ResponseCodeEnum.CODE_INVALID.getMsg());
    }
    public static final ResData<Void> LOGIN_SUCCESS=
            new ResData<>(ResponseCodeEnum.LOGIN_SUCCESS.getCode(),ResponseCodeEnum.LOGIN_SUCCESS.getMsg());

    public static final ResData<Void> LOGIN_FILA=
            new ResData<>(ResponseCodeEnum.LOGIN_FIAL.getCode(), ResponseCodeEnum.LOGIN_FIAL.getMsg());

    public static final ResData<Void> NOT_LOGIN=
            new ResData<>(ResponseCodeEnum.NOT_LOGIN.getCode(), ResponseCodeEnum.NOT_LOGIN.getMsg());

    public static final ResData<Void> NOT_AUTH=
            new ResData<>(ResponseCodeEnum.NOT_AUTH.getCode(), ResponseCodeEnum.NOT_AUTH.getMsg());

    public static final ResData<Void> LOGINOUT=
            new ResData<>(ResponseCodeEnum.LOGINOUT.getCode(), ResponseCodeEnum.LOGINOUT.getMsg());

    public static final ResData<Void> ACCOUNT_NO=
            new ResData<>(ResponseCodeEnum.ACCOUNT_NO.getCode(), ResponseCodeEnum.ACCOUNT_NO.getMsg());

    public static final ResData<Void> CODE_FAIL=
            new ResData<>(ResponseCodeEnum.CODE_FAIL.getCode(), ResponseCodeEnum.CODE_FAIL.getMsg());

    public static final ResData<Void> REGISTER_SUCCESS=
            new ResData<>(ResponseCodeEnum.REGISTER_SUCCESS.getCode(), ResponseCodeEnum.REGISTER_SUCCESS.getMsg());

    public static final ResData<Void> ACCOUNT_DISABLE=
            new ResData<>(ResponseCodeEnum.ACCOUNT_DISABLE.getCode(), ResponseCodeEnum.ACCOUNT_DISABLE.getMsg());


    public ResData(Integer code, T data) {
        this.code = code;
        this.data = data;
    }

    public ResData(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
}
